package com.itec.learn.spring.aop;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import java.util.logging.Logger;

/**
 * @author chenyiqun
 */
public class LogInterceptor implements MethodInterceptor {

    private Logger logger = Logger.getLogger(getClass().getName());

    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        logger.info(methodInvocation.getMethod().getName() + " method starts...");
        Object result = methodInvocation.proceed();
        logger.info(methodInvocation.getMethod().getName() + " method ends...");
        return result;
    }
}
